<template>
  <div class="container">
    <div class="title clear">
      <i class="icon iconfont iconfanhui1" @click="goBack"></i>
      <div class="descBox">{{ projectScore.projectName }}</div>
      <div class="score fontColorTheme">
        <span>{{
          $route.query.year + '-' + $route.query.month + '-' + $route.query.day
        }}</span>
        /
        <span>{{ projectScore.score == null ? '--' : projectScore.score }}</span
        >分 / 评级：
        <span>{{
          projectScore.gradeLevel
            ? projectScore.gradeLevel === 'O'
              ? '其他'
              : projectScore.gradeLevel
            : '--'
        }}</span>
      </div>
    </div>
    <div class="mainCon">
      <ESreduceTable
        :tableList="negetivePoints"
        scoreType="project"
      ></ESreduceTable>
    </div>
  </div>
</template>

<script>
import topTitle from '@/components/publicCom/topTitle'
import ESreduceTable from './ESreduceTable'
export default {
  name: 'projectHistoryScoreDetailEs',
  components: {
    topTitle,
    ESreduceTable,
  },
  data() {
    return {
      isScore: true,
      titleText: '历史评价详情',
      isShowDetail: '',
      detailData: {},
      projectScore: {},
      negetivePoints: [],
      projectId: '',
      projectScoreId: '',
      back: true,
    }
  },
  created() {
    this.projectId = this.$route.query.projectId
    this.projectScoreId = this.$route.query.projectScoreId
    this.getScoreData()
    this.getESScoreData()
  },
  methods: {
    goBack() {
      this.$router.push({
        path: '/home/enterpriseScore/projectHistoryScoreList',
        name: 'projectHistoryScoreList',
        data: {
          projectId: this.projectId,
          projectScoreId: this.projectScoreId,
        },
      })
      this.$store.commit('GOBACK_NAME', {
        oldUrl: '/home/enterpriseScore/projectScoreList',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
    // 项目评分详情
    getScoreData() {
      this.axios({
        method: 'post',
        url: 'api-ps/creditProjScorDetail/expand/findProjectScoreDetail',
        data: {
          projectId: this.projectId,
          projectScoreId: this.projectScoreId,
        },
      })
        .then(async (resp) => {
          if (!resp.data.hasError) {
            this.detailData = resp.data.result
            // this.negetivePoints = this.detailData.indexDimList;
            this.projectScore = this.detailData.projectScore || {}
          } else {
            this.$message({
              type: 'error',
              message: resp.data.errorMsg,
            })
          }
        })
        .catch((error) => {
          this.$message({
            type: 'error',
            message: '数据获取失败',
          })
        })
    },
    // 恩施项目评分扣分详情
    getESScoreData() {
      this.axios({
        method: 'post',
        url: 'api-ps/creditProjScorDetail/expand/findPCreditIndexByIdES',
        data: {
          projectId: this.projectId,
          projectScoreId: this.projectScoreId,
          appType: '20',
        },
      })
        .then(async (resp) => {
          if (!resp.data.hasError) {
            let results = resp.data.result
            this.negetivePoints = results
          } else {
            this.$message({
              type: 'error',
              message: resp.data.errorMsg,
            })
          }
        })
        .catch((error) => {
          this.$message({
            type: 'error',
            message: '数据获取失败',
          })
        })
    },
  },
}
</script>

<style scoped lang="less">
.container {
  .title {
    height: 56px;
    font-size: 0;
    background-color: #fff;
    border-bottom: 1px solid #e3e7e9;
    padding: 0 24px;
    .iconfanhui1 {
      font-size: 18px;
      margin-top: 18px;
      float: left;
    }
    .descBox {
      font-size: 18px;
      color: #333;
      font-weight: 700;
      line-height: 56px;
      float: left;
    }
    .score {
      font-size: 24px;
      color: #333333;
      font-weight: bold;
      line-height: 56px;
      float: right;
    }
  }
  .mainCon {
    padding: 24px;
  }
}
</style>
